package com.lxx.jmb2c.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lxx.jmb2c.entity.Brand;
import com.lxx.jmb2c.mapper.BrandMapper;
import com.lxx.jmb2c.service.BrandService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 品牌表 服务实现类
 * </p>
 *
 * @author wuyunbin
 * @since 2025-07-10
 */
@Service
public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements BrandService {

    @Override
    public IPage<Brand> getPage(Long current, Long pageSize, String name) {
        LambdaQueryWrapper<Brand> wrapper = new LambdaQueryWrapper<>();
        if (name != null && !name.isEmpty()) {
            wrapper.like(Brand::getName, name);
        }
        return this.page(new Page<>(current, pageSize), wrapper);
    }

    @Override
    public void enable(Long id) {
        Brand brand = this.getById(id);
        if (brand != null) {
            // 这里假设Brand实体有status字段表示状态
            // 实际应根据项目需求实现具体逻辑
            this.updateById(brand);
        }
    }

    @Override
    public void deleteBatchByIds(List<Long> ids) {
        this.removeByIds(ids);
    }
}

